<?php
	class Home extends Controller 
	{
		function Home()
		{
			//error_reporting(0);
			parent::Controller();
			$this->load->model('admin_model');
		}
		function index()
		{
			if($this->session->userdata('uid') > 0)
			{
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('dashboard/dashboard.php');
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
				else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		function citylist()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['city']))
					{
					$this->session->set_userdata('errmsg','Error : City Name is empty. Enter the City Name.');
					redirect(WEB_URL . 'home/citylist');
					}
					else
					{
					$type=0;
					$parentid=0;
					$cityid=$this->admin_model->insertcitylist($_POST['city'],$type,$parentid);
					if($cityid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Cityname inserted successfully');
						}
						elseif($cityid == -1){
						$this->session->set_userdata('errmsg',' Error: Cityname already exists');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Cityname not inserted.Try again');
						}
					}
					redirect(WEB_URL . 'home/citylist');
				
				}
				$config['base_url'] = WEB_URL.'home/citylist/';
			$config['total_rows'] =$this->db->count_all('citylist');
			$config['per_page'] = '5';
			$config['uri_segment'] = 3;
			$this->pagination->initialize($config);
			$offset = (int)$this->uri->segment(3);
				$data['citylist']=$this->admin_model->fetchcitylistpage($offset,(int)$config['per_page']);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('citylist/citylistview.php',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function citylocation()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['city'])||empty($_POST['cityarea']))
					{
					$this->session->set_userdata('errmsg','Error : Empty Fields. Enter the value.');
					redirect(WEB_URL . 'home/citylocation');
					}
					else
					{
					$type=1;
					$cityareaid=$this->admin_model->insertcityarea($_POST['city'],$_POST['cityarea'],$type);
					if($cityareaid > 0)
						{
							$this->session->set_userdata('errmsg','Message:City Location Details inserted successfully');
						}
						elseif($cityareaid == -1){
						$this->session->set_userdata('errmsg',' Error: City Location already exists');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Citylocation value not inserted.Try again');
						}
					}
					redirect(WEB_URL . 'home/citylocation');
				
				}
				$config['base_url'] = WEB_URL.'home/citylocation/';
			$config['total_rows'] =$this->db->count_all('citylist');
			$config['per_page'] = '5';
			$config['uri_segment'] = 3;
			$this->pagination->initialize($config);
			$offset = (int)$this->uri->segment(3);
				$data['citylist']=$this->admin_model->fetchcitylist();
				$data['cityarea']=$this->admin_model->fetchcityareapage($offset,(int)$config['per_page']);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('citylist/cityareaview.php',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function category()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['proptype'])||empty($_POST['category']))
					{
					$this->session->set_userdata('errmsg','Error : Category field is empty. Enter the Category field.');
					redirect(WEB_URL . 'home/category');
					}
					else
					{
					$cat=$_POST['category'];
					$category = ucwords(strtolower($cat));
					$categoryid=$this->admin_model->insertcategory($_POST['proptype'],$category);
					if($categoryid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Category inserted successfully');
						}
						elseif($categoryid == -1){
						$this->session->set_userdata('errmsg',' Error: Category already exists under this type');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Category not inserted.Try again');
						}
					}
					redirect(WEB_URL . 'home/category');
				
				}
				$config['base_url'] = WEB_URL.'home/category/';
			$config['total_rows'] =$this->db->count_all('category');
			$config['per_page'] = '5';
			$config['uri_segment'] = 3;
			$this->pagination->initialize($config);
			$offset = (int)$this->uri->segment(3);
				$data['proptype']=$this->admin_model->fetchproptype();
				$data['category']=$this->admin_model->fetchcategorypage($offset,(int)$config['per_page']);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('category/categorylistview.php',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function property_types()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['proptype']))
					{
					$this->session->set_userdata('errmsg','Error : Property Type field is empty. Enter the Category field.');
					redirect(WEB_URL . 'home/property_types');
					}
					else
					{
					$proptypeid=$this->admin_model->insertproptype($_POST['proptype']);
					if($proptypeid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Property type inserted successfully');
						}
						elseif($proptypeid == -1){
						$this->session->set_userdata('errmsg',' Error: Property type already exists.');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Property type not inserted.Try again');
						}
					}
					redirect(WEB_URL . 'home/property_types');
				
				}
				$data['proptype']=$this->admin_model->fetchproptype();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('property/proptypeview.php',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addproperty()
		{
			if($this->session->userdata('uid') > 0)
			{
			$propertytype=$this->uri->segment(3);
			//print $propertytype;
			$data['propertytype']=$this->admin_model->fetchpropertytype($propertytype);
			$data['citylist']=$this->admin_model->fetchcitylist();
			$data['category']=$this->admin_model->fetchresidentialcategory($propertytype);
			$config['base_url'] = WEB_URL.'home/addproperty/residential/';
			$config['total_rows'] =$this->db->count_all('propertymaster');
			$config['per_page'] = '5';
			$config['uri_segment'] = 4;
			$config['full_tag_open'] = '<p>';
               $config['full_tag_close'] = '</p>';
			$this->pagination->initialize($config);
			$offset = (int)$this->uri->segment(4);
			$data['property']=$this->admin_model->fetchpropertypage($offset,(int)$config['per_page']);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('property/addpropertyview.php',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addpropertyvalue()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['cityname'])||empty($_POST['propcategory']))
					{
					$this->session->set_userdata('errmsg','Error : Please select fields first');
					redirect(WEB_URL . 'home/addproperty/residential');
					}
					else
					{
						
						$data['cityid']=$_POST['cityname'];
						$data['proptypeid']=$_POST['proptypeid'];
						$data['propcategory']=$_POST['propcategory'];
						$var1=$data['propcategory'];
						$this->session->set_userdata('cityid',$_POST['cityname']);
						$this->session->set_userdata('proptypeid',$_POST['proptypeid']);
						$this->session->set_userdata('propcategory',$_POST['propcategory']);
						//print $var1;
					}
					//redirect(WEB_URL . 'home/property_types');
				
				}
				//print $var1;
				//$this->session->set_userdata('cityid',$_POST['cityname']);
				$data['cityid']=$this->session->userdata('cityid');
				$data['proptypeid']=$this->session->userdata('proptypeid');
				$data['propcategory']=$this->session->userdata('propcategory');
				$propcategory=$data['propcategory'];
				$categoryname=$this->admin_model->fetchcategoryname($propcategory);
			$data['banklist']=$this->admin_model->fetchbanklist();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			if($categoryname=='Apartments')
			{
			$this->load->view('property/addpropertyapartments',$data);
			}
			else
			{
				$this->load->view('property/addpropertyvalue',$data);
			}
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addpropertyapartmentsdetails()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_POST['buildername'])||empty($_POST['address'])||empty($_POST['project'])||empty($_POST['developer']))
					{
					$this->session->set_userdata('errmsg','Error : Field is/are empty. Enter the value first.');
					redirect(WEB_URL . 'home/addpropertyvalue');
					}
					else
					{
										
					
        $where = stripslashes($_POST['address']);
        $whereurl = urlencode($where);
// Note - Google key is domain specific!
$location = file("http://maps.google.com/maps/geo?q=$whereurl
&output=csv&key=ABQIAAAAvp3__HwvT3VkixIIbsW0axQuKI_6t1bH2P0vC
I_Q8jfpn8qdNBQMnneljxh9czilkau_bYSCXteS_A");
// Sample - $location[0]="200,8,51.369318,-2.133457";
        list ($stat,$acc,$lat,$long) = explode(",",$location[0]);
        
		//print $lat;
		//print $long;
					if(isset($_FILES['logofileproject'])||isset($_FILES['logofilebuilder']))
					{
					$ext = end(explode(".",strtolower($_FILES['logofileproject']['name'])));
					
					$ext1 = end(explode(".",strtolower($_FILES['logofilebuilder']['name'])));
					
					if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp") && ($ext1 == "jpg" || $ext1 =="jpeg" || $ext1 =="gif" || $ext1 =="png" || $ext1 =="bmp"))
					{
			
			$name 	= rand(111111,888888) . "." . $ext;
			move_uploaded_file($_FILES['logofileproject']['tmp_name'], ROOT_PATH . 'projectimgupload/'.$name);
			
			
			
			$name1 = rand(111111,888888) . "." . $ext1;
			move_uploaded_file($_FILES['logofilebuilder']['tmp_name'], ROOT_PATH . 'projectimgupload/'.$name1);
			
					/*if(isset($_POST['propertyongoing']))
					{
						$ongoing=1;
					}
					else
					{
						$ongoing=0;
					}
					
					if(isset($_POST['propertyprelaunch']))
					{
						$prelaunch=1;
					}
					else
					{
						$prelaunch=0;
					}*/
					$propertyid=$this->admin_model->insertapartmentpropertydetails($_POST['propertyname'],$name,$_POST['address'],$_POST['buildername'],$name1,$_POST['project'],$_POST['developer'],$lat,$long,$_POST['propertycategory'],$_POST['propertytype'],$_POST['propertycity']);
					
					$data['banklist']=$this->admin_model->fetchbanklist();
					foreach($data['banklist'] as $bank)
				{
					$bankidval = $bank['bankid'];
					$ids = 'bank'.$bankidval ;				
					if(isset($_POST[$ids]))
						{						
							$iactid = $bankidval ;
					$actinsid = $this->admin_model->addapprovedbankid($propertyid,$iactid); 
						}
				}
					
					if($propertyid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Property Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Property Details not inserted.Try again');
						}}
						else
					{
						$this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
						redirect(WEB_URL . 'home/addpropertyvalue');
					}
					
					redirect(WEB_URL . 'home/addapartmenttowerdetails/'.$propertyid);
				}}
				}
				
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addapartmenttowerdetails()
		{
			if($this->session->userdata('uid') > 0)
			{
				$propertyid=$this->uri->segment(3);
				
				if(isset($_POST['submit']))
				{
				
					if(empty($_POST['towername']))
					{
					$this->session->set_userdata('errmsg','Error : Tower name is empty.');
					redirect(WEB_URL . 'home/addapartmenttowerdetails/'.$propertyid);
					}
					else
					{
						if(isset($_POST['propertyongoing']))
					{
						$ongoing=1;
					}
					else
					{
						$ongoing=0;
					}
					
					if(isset($_POST['propertyprelaunch']))
					{
						$prelaunch=1;
					}
					else
					{
						$prelaunch=0;
					}
						$towerdescid=$this->admin_model->inserttowerdesc($_POST['propertyid'],$_POST['towername'],$_POST['floornumber'],$_POST['apartmentsperfloor'],$_POST['propertycompletion'],$_POST['propertypossession'],$ongoing,$prelaunch);
						
						if($towerdescid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Tower Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Tower Details not inserted.Try again');
						}
					}
					
				redirect(WEB_URL . 'home/addapartmenttowerdetails/'.$propertyid);
				}
				
				//print $var1;
				$data['propertyid']=$propertyid;
			$data['propertyname']=$this->admin_model->fetchpropertyname($propertyid);
			$data['towerdesc']=$this->admin_model->fetchtowerdesc();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('property/apartmenttowerdesc',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addpropertydetails()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_POST['buildername']))
					{
					$this->session->set_userdata('errmsg','Error : Project name/Builder name field cant left empty. Enter the value first.');
					redirect(WEB_URL . 'home/addpropertyvalue');
					}
					else
					{
										
					
        $where = stripslashes($_POST['address']);
        $whereurl = urlencode($where);
// Note - Google key is domain specific!
$location = file("http://maps.google.com/maps/geo?q=$whereurl
&output=csv&key=ABQIAAAAvp3__HwvT3VkixIIbsW0axQuKI_6t1bH2P0vC
I_Q8jfpn8qdNBQMnneljxh9czilkau_bYSCXteS_A");
// Sample - $location[0]="200,8,51.369318,-2.133457";
        list ($stat,$acc,$lat,$long) = explode(",",$location[0]);
        
		//print $lat;
		//print $long;
					if(isset($_FILES['logofileproject'])||isset($_FILES['logofilebuilder']))
					{
					$ext = end(explode(".",strtolower($_FILES['logofileproject']['name'])));
					
					$ext1 = end(explode(".",strtolower($_FILES['logofilebuilder']['name'])));
					
					if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp") && ($ext1 == "jpg" || $ext1 =="jpeg" || $ext1 =="gif" || $ext1 =="png" || $ext1 =="bmp"))
					{
			
			$name 	= rand(111111,888888) . "." . $ext;
			move_uploaded_file($_FILES['logofileproject']['tmp_name'], ROOT_PATH . 'projectimgupload/'.$name);
			
			
			
			$name1 = rand(111111,888888) . "." . $ext1;
			move_uploaded_file($_FILES['logofilebuilder']['tmp_name'], ROOT_PATH . 'projectimgupload/'.$name1);
			
					if(isset($_POST['propertyongoing']))
					{
						$ongoing=1;
					}
					else
					{
						$ongoing=0;
					}
					
					if(isset($_POST['propertyprelaunch']))
					{
						$prelaunch=1;
					}
					else
					{
						$prelaunch=0;
					}
					$propertyid=$this->admin_model->insertpropertydetails($_POST['propertyname'],$name,$_POST['address'],$_POST['buildername'],$name1,$_POST['project'],$_POST['developer'],$lat,$long,$_POST['propertycategory'],$_POST['propertytype'],$_POST['propertycity']);
					
					$addpropertyid=$this->admin_model->insertaddpropertydetails($propertyid,$_POST['propertybedrooms'],$_POST['propertyprice'],$_POST['propertylandarea'],$_POST['propertybuiltuparea'],$_POST['propertycompletion'],$_POST['propertypossession'],$ongoing,$prelaunch);
					
					$data['banklist']=$this->admin_model->fetchbanklist();
					foreach($data['banklist'] as $bank)
				{
					$bankidval = $bank['bankid'];
					$ids = 'bank'.$bankidval ;				
					if(isset($_POST[$ids]))
						{						
							$iactid = $bankidval ;
					$actinsid = $this->admin_model->addapprovedbankid($propertyid,$iactid); 
						}
				}
					
					if($propertyid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Property Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Property Details not inserted.Try again');
						}}
						else
					{
						$this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
					}
					
					redirect(WEB_URL . 'home/addproperty/residential');
				}}
				}
				
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addfloorplan()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['property']))
					{
					$this->session->set_userdata('errmsg','Error : Select drop down first.');
					redirect(WEB_URL . 'home/addfloorplan');
					}
					else
					{
						if(isset($_FILES["ap_file1"]))
			{
			$ext = end(explode(".",strtolower($_FILES['ap_file1']['name'])));
			
			if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
					
					$basepath =  ROOT_PATH . "floorplanimg/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['ap_file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    else{
                            $this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
                    }
                    if(strlen($imgpath) > 4)
                    {
                        $floorplanid=$this->admin_model->insertapartmentfloorplan($_POST['tower'],$_POST['ap_bedrooms'],$_POST['ap_range1'],$_POST['ap_range2'],$_POST['ap_price'],$_POST['ap_additional'],$newfilename,$thumbfilename);
                    }
								
					if($floorplanid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Apartment Floor Plan Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Apartment Floor Plan Details not inserted.Try again');
						}}
						
						
					
					redirect(WEB_URL . 'home/addfloorplan');
				}}
				
				elseif(isset($_POST['villasubmit']))
				{
					if(empty($_POST['vi_property']))
					{
					$this->session->set_userdata('errmsg','Error : Select drop down first.');
					redirect(WEB_URL . 'home/addfloorplan');
					}
					else
					{
						if(isset($_FILES["vi_file1"]))
			{
			$ext = end(explode(".",strtolower($_FILES['vi_file1']['name'])));
			print $ext;
			if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
					
					$basepath =  ROOT_PATH . "floorplanimg/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['vi_file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    else{
                            $this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
                    }
                    if(strlen($imgpath) > 4)
                    {
                        $floorplanid=$this->admin_model->insertvillafloorplan($_POST['vi_property'],$_POST['vi_type'],$newfilename,$thumbfilename);
						print $floorplanid;
                    }
								
					if($floorplanid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Villa Floor Plan Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Villa Floor Plan Details not inserted.Try again');
						}}
						
						
					
					redirect(WEB_URL . 'home/addfloorplan');
				}
				}
				
				elseif(isset($_POST['independentsubmit']))
				{
					if(empty($_POST['ih_property']))
					{
					$this->session->set_userdata('errmsg','Error : Select drop down first.');
					redirect(WEB_URL . 'home/addfloorplan');
					}
					else
					{
						if(isset($_FILES["ih_file1"]))
			{
			$ext = end(explode(".",strtolower($_FILES['ih_file1']['name'])));
			print $ext;
			if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
					
					$basepath =  ROOT_PATH . "floorplanimg/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['ih_file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    else{
                            $this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
                    }
                    if(strlen($imgpath) > 4)
                    {
                        $floorplanid=$this->admin_model->insertindependenthousefloorplan($_POST['ih_property'],$_POST['ih_type'],$newfilename,$thumbfilename);
						print $floorplanid;
                    }
								
					if($floorplanid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Independent house Floor Plan Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Independent house Floor Plan Details not inserted.Try again');
						}}
						
						
					
					redirect(WEB_URL . 'home/addfloorplan');
				}
				}
				
				
				//print_r($data);
				//$apartmentcat=$this->admin_model->fetchapartmentcategory();
				$data['propertyname']=$this->admin_model->fetchproperty();
				$data['categoryname']=$this->admin_model->fetchcategorylist();
				$data['propertyfloor']=$this->admin_model->fetchpropertyfloor();
				$data['propertylist']=$this->admin_model->fetchpropertycategorywise();
				$data['propertyvillalist']=$this->admin_model->fetchpropertyvilla();
				$data['propertyindependentlist']=$this->admin_model->fetchpropertyindependenthouse();
				$data['propertyapartmentfloorplan']=$this->admin_model->fetchapartmentfloorplan();
				$data['propertyvillafloorplan']=$this->admin_model->fetchvillafloorplan();
				$data['propertyindependenthousefloor']=$this->admin_model->fetchindependenthousefloorplan();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('propertyfloorplan/addpropertyfloorplan',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addvillafloorplan()
		{
			if($this->session->userdata('uid') > 0)
			{
									
			$ext = end(explode(".",strtolower($_FILES['vi_file1']['name'])));
			print $ext;
			if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
					
					$basepath =  ROOT_PATH . "floorplanimg/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['vi_file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    else{
                            $this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
                    }
                    if(strlen($imgpath) > 4)
                    {
                        $floorplanid=$this->admin_model->insertvillafloorplan($_POST['vi_property'],$_POST['vi_type'],$newfilename,$thumbfilename);
						print $floorplanid;
                    }
								
					if($floorplanid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Villa Floor Plan Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Villa Floor Plan Details not inserted.Try again');
						}
						
						
					
				//	redirect(WEB_URL . 'home/addvillafloorplan');
				
				
				//print_r($data);
				//$apartmentcat=$this->admin_model->fetchapartmentcategory();
				$data['propertyname']=$this->admin_model->fetchproperty();
				$data['categoryname']=$this->admin_model->fetchcategorylist();
				$data['propertyfloor']=$this->admin_model->fetchpropertyfloor();
				$data['propertylist']=$this->admin_model->fetchpropertycategorywise();
				$data['propertyvillalist']=$this->admin_model->fetchpropertyvilla();
				$data['propertyindependentlist']=$this->admin_model->fetchpropertyindependenthouse();
				$data['propertyvillafloorplan']=$this->admin_model->fetchvillafloorplan();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('propertyfloorplan/addpropertyfloorplan',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addcommercialproperty()
		{
			if($this->session->userdata('uid') > 0)
			{
			$propertytype=$this->uri->segment(3);
			//print $propertytype;
			$data['propertytype']=$this->admin_model->fetchpropertytype($propertytype);
			$data['citylist']=$this->admin_model->fetchcitylist();
			$data['category']=$this->admin_model->fetchcommercialcategory($propertytype);
			$config['base_url'] = WEB_URL.'home/addcommercialproperty/commercial/';
			$config['total_rows'] =$this->db->count_all('propertycommercial');
			$config['per_page'] = '5';
			$config['uri_segment'] = 4;
			$config['full_tag_open'] = '<p>';
               $config['full_tag_close'] = '</p>';
			$this->pagination->initialize($config);
			$offset = (int)$this->uri->segment(4);
			$data['commercialproperty']=$this->admin_model->fetchcommercialpropertypage($offset,(int)$config['per_page']);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('property/addcommercialpropertyview',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addcommercialpropertyvalue()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['cityname'])||empty($_POST['propcategory']))
					{
					$this->session->set_userdata('errmsg','Error : Please select fields first');
					redirect(WEB_URL . 'home/addcommercialproperty/commercial');
					}
					else
					{
						
						$data['cityid']=$_POST['cityname'];
						$data['proptypeid']=$_POST['proptypeid'];
						$data['propcategory']=$_POST['propcategory'];
						$var1=$data['propcategory'];
						$this->session->set_userdata('cityid',$_POST['cityname']);
						$this->session->set_userdata('proptypeid',$_POST['proptypeid']);
						$this->session->set_userdata('propcategory',$_POST['propcategory']);

					}
					//redirect(WEB_URL . 'home/property_types');
				
				}
				//print_r($data);
				$data['cityid']=$this->session->userdata('cityid');
				$data['proptypeid']=$this->session->userdata('proptypeid');
				$data['propcategory']=$this->session->userdata('propcategory');
				$data['banklist']=$this->admin_model->fetchbanklist();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('property/addcommercialpropertyvalue',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addcommercialpropertydetails()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_POST['address']))
					{
					$this->session->set_userdata('errmsg','Error : Project name and address field cant left empty. Enter the value first.');
					redirect(WEB_URL . 'home/addcommercialpropertyvalue');
					}
					else
					{
					
        $where = stripslashes($_POST['address']);
        $whereurl = urlencode($where);
// Note - Google key is domain specific!
$location = file("http://maps.google.com/maps/geo?q=$whereurl
&output=csv&key=ABQIAAAAvp3__HwvT3VkixIIbsW0axQuKI_6t1bH2P0vC
I_Q8jfpn8qdNBQMnneljxh9czilkau_bYSCXteS_A");
// Sample - $location[0]="200,8,51.369318,-2.133457";
        list ($stat,$acc,$lat,$long) = explode(",",$location[0]);
        
		//print $lat;
		//print $long;
				if(isset($_FILES['logofileproject'])||isset($_FILES['logofilebuilder']))
					{
					$ext = end(explode(".",strtolower($_FILES['logofileproject']['name'])));
					$ext1 = end(explode(".",strtolower($_FILES['logofilebuilder']['name'])));
					
					if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp") && ($ext1 == "jpg" || $ext1 =="jpeg" || $ext1 =="gif" || $ext1 =="png" || $ext1 =="bmp"))
					{
                        $name = rand(111111,888888) . "." . $ext ;                        
                        move_uploaded_file($_FILES['logofileproject']['tmp_name'], ROOT_PATH . 'projectimgupload/'.$name);
						
						$name1 = rand(111111,888888) . "." . $ext1 ;                        
                        move_uploaded_file($_FILES['logofilebuilder']['tmp_name'], ROOT_PATH . 'projectimgupload/'.$name1);
						
					   if(isset($_POST['propertyongoing']))
					{
						$ongoing=1;
					}
					else
					{
						$ongoing=0;
					}
					
					if(isset($_POST['propertyprelaunch']))
					{
						$prelaunch=1;
					}
					else
					{
						$prelaunch=0;
					}               
                    
					$commercialpropertyid=$this->admin_model->insertcommercialpropertydetails($_POST['propertyname'],$name,$_POST['buildername'],$name1,$_POST['address'],$_POST['project'],$_POST['developer'],$lat,$long,$_POST['propertycategory'],$_POST['propertycity'],$_POST['propertytype']);
					
					$commercialid=$this->admin_model->insertcommercialaddproperty($commercialpropertyid,$_POST['propertyfloors'],$ongoing,$prelaunch,$_POST['propertycompletion'],$_POST['propertypossession']);
					
					$data['banklist']=$this->admin_model->fetchbanklist();
					foreach($data['banklist'] as $bank)
				{
					$bankidval = $bank['bankid'];
					$ids = 'bank'.$bankidval ;				
					if(isset($_POST[$ids]))
						{						
							$iactid = $bankidval ;
					$actinsid = $this->admin_model->addcommercialapprovedbankid($commercialpropertyid,$iactid); 
						}
				}
					
					if($commercialpropertyid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Commercial Property Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Commercial Property Details not inserted.Try again');
						}}
						else
					{
						$this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
					}
					
					redirect(WEB_URL . 'home/addcommercialproperty/commercial','refresh');
				
				}}
				
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}}
		
		function addcommercialfloorplan()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['commercialpropertyname']))
					{
					$this->session->set_userdata('errmsg','Error : Select drop down first.');
					redirect(WEB_URL . 'home/addcommercialfloorplan');
					}
					else
					{
						if(isset($_FILES["file1"]))
			{
			$ext = end(explode(".",strtolower($_FILES['file1']['name'])));
			
			if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
					
					$basepath =  ROOT_PATH . "floorplanimg/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    else{
                            $this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
                    }
                    if(strlen($imgpath) > 4)
                    {
                        $floorplanid=$this->admin_model->insertcommercialpropertyfloorplan($_POST['commercialpropertyname'],$_POST['commercialfloorsize'],$_POST['pricepersqft'],$newfilename,$thumbfilename);
                    }
								
					if($floorplanid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Commercial Floor Plan Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Commercial Floor Plan Details not inserted.Try again');
						}}
						
						
					
					redirect(WEB_URL . 'home/addcommercialfloorplan');
				}}

			
				
				//print_r($data);
				
				$data['commercialpropertyname']=$this->admin_model->fetchcommercialprojectname();
				$data['commercialpropertyfloor']=$this->admin_model->fetchcommercialpropertyfloor();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('propertyfloorplan/addcommercialpropertyfloorplan',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addcommercialplan()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_POST['commercialimagetype']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addcommercialplan');
					}
					else
					{
						if(isset($_FILES["file1"]))
			{
			$ext = end(explode(".",strtolower($_FILES['file1']['name'])));
			
			if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
					
					$basepath =  ROOT_PATH . "planimg/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    else{
                            $this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
                    }
                    if(strlen($imgpath) > 4)
                    {
                        $planid=$this->admin_model->insertcommercialplan($_POST['propertyname'],$_POST['commercialimagetype'],$newfilename,$thumbfilename);
                    }
								
					if($planid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Commercial Plan Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Commercial Plan Details not inserted successfully');
						}}
						
					
					redirect(WEB_URL . 'home/addcommercialplan');
				}}
				
				//print_r($data);
				$data['commercialcategory']=$this->admin_model->fetchcommercialcategoryname();
				//$data['commercialpropertyname']=$this->admin_model->fetchcommercialproperty();
				$data['commercialplan']=$this->admin_model->fetchcommercialplan();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('propertyplan/addcommercialpropertyplan',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addresidentialplan()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_POST['category']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Select Drop down first.');
					redirect(WEB_URL . 'home/addresidentialplan');
					}
					else
					{
						if(isset($_FILES["file1"]))
			{
			$ext = end(explode(".",strtolower($_FILES['file1']['name'])));
			
			if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
			
			$basepath =  ROOT_PATH . "planimg/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    else{
                            $this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
                    }
                    if(strlen($imgpath) > 4)
                    {
                        $residentialplanid=$this->admin_model->insertresidentialplan($_POST['propertyname'],$_POST['residentialimagetype'],$newfilename,$thumbfilename);
                    }
			
			
					if($residentialplanid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Residential Plan Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
						}}
						
					
					redirect(WEB_URL . 'home/addresidentialplan');
				}}
				
				//print_r($data);
				$data['propertycategoryname']=$this->admin_model->fetchcategorylist();
				$data['residentialpropertyname']=$this->admin_model->fetchproperty();
				$data['residentialplan']=$this->admin_model->fetchresidentplan();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('propertyplan/addresidentialpropertyplan',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addcommercialamenities()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_POST['commercialamenities']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addcommercialamenities');
					}
					else
					{
						
						$commercialamenitiesid=$this->admin_model->insertcommercialamenities($_POST['propertyname'],$_POST['commercialamenities']);
					if($commercialamenitiesid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Commercial Amenities Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Commercial Amenities Details not inserted.Try again');
						}
					}
					redirect(WEB_URL . 'home/addcommercialamenities');
				
				}
				//print_r($data);
				$data['commercialcategory']=$this->admin_model->fetchcommercialcategoryname();
				//$data['commercialpropertyname']=$this->admin_model->fetchcommercialproperty();
				$data['commercialamenities']=$this->admin_model->fetchcommercialamenities();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('amenities/addcommercialamenities',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addresidentialspecification()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_POST['specificationname'])||empty($_POST['category']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addresidentialspecification');
					}
					else
					{
						$specificationid=$this->admin_model->insertresidentialspecification($_POST['propertyname'],$_POST['specificationname']);
					if($specificationid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Specification Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Specification Details not inserted.Try again');
						}
					}
					redirect(WEB_URL . 'home/addresidentialspecification');
				
				}
				//print_r($data);
				$data['propertycategoryname']=$this->admin_model->fetchcategorylist();
				$data['propertyname']=$this->admin_model->fetchproperty();
				$data['residentialspecification']=$this->admin_model->fetchspecification();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('amenities/addresidentialspecification',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addresidentialamenities()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_POST['propertyamenities'])||empty($_POST['category']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addresidentialamenities');
					}
					else
					{
						$amenitiesid=$this->admin_model->insertresidentialamenitiesname($_POST['propertyname'],$_POST['propertyamenities']);
					if($amenitiesid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Amenities Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Amenities Details not inserted.Try again');
						}
					}
					redirect(WEB_URL . 'home/addresidentialamenities');
				
				}
				//print_r($data);
				$data['propertycategoryname']=$this->admin_model->fetchcategorylist();
				$data['propertyname']=$this->admin_model->fetchproperty();
				$data['residentialamenities']=$this->admin_model->fetchamenities();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('amenities/addresidentialamenities',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addcommercialbuildingelevation()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_FILES["file1"]))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addcommercialbuildingelevation');
					}
					else
					{
						if(isset($_FILES["file1"]))
			{
			$ext = end(explode(".",strtolower($_FILES['file1']['name'])));
			
			if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
					
					$basepath =  ROOT_PATH . "elevationimg/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    else{
                            $this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
                    }
                    if(strlen($imgpath) > 4)
                    {
                        $elevationid=$this->admin_model->insertcommercialcaption($_POST['propertyname'],$_POST['commercialimagecaption'],$newfilename,$thumbfilename);
                    }
								
					if($elevationid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Elevation Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Elevation Details inserted successfully');
						}}
					
					redirect(WEB_URL . 'home/addcommercialbuildingelevation');
				}}
				
				//print_r($data);
				$data['commercialcategory']=$this->admin_model->fetchcommercialcategoryname();
				//$data['commercialpropertyname']=$this->admin_model->fetchcommercialproperty();
				$data['commercialelevation']=$this->admin_model->fetchcommercialelevation();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('elevation/addcommercialbuildingelevation',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addresidentialelevation()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_FILES['file1']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addresidentialelevation');
					}
					else
					{
						if(isset($_FILES["file1"]))
			{
			$ext = end(explode(".",strtolower($_FILES['file1']['name'])));
			
			if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
					
					$basepath =  ROOT_PATH . "elevationimg/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    else{
                            $this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
                    }
                    if(strlen($imgpath) > 4)
                    {
                        $residentialelevationid=$this->admin_model->insertresidentialcaption($_POST['propertyname'],$_POST['residentialcaption'],$newfilename,$thumbfilename);
                    }
			
									
					if($residentialelevationid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Building Elevation Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Building Elevation Details not inserted.Try again');
						}}
						
						else
						{
							$this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
						}
					
					redirect(WEB_URL . 'home/addresidentialelevation');
				}}
				
				//print_r($data);
				$data['propertycategoryname']=$this->admin_model->fetchcategorylist();
				$data['propertyname']=$this->admin_model->fetchproperty();
				$data['residentialelevation']=$this->admin_model->fetchresidentialelevation();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('elevation/addresidentialbuildingelevation',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addprofessionals()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['firstname'])||empty($_POST['lastname'])||empty($_POST['designation']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addprofessionals');
					}
					else
					{
					$professionalid=$this->admin_model->insertprofessional($_POST['firstname'],$_POST['lastname'],$_POST['designation']);
					if($professionalid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Professional Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Professional Details not inserted.Try again');
						}
					}
					redirect(WEB_URL . 'home/addprofessionals');
				
				}
				$data['professional']=$this->admin_model->fetchprofessionallist();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('professionals/addprofessionals.php',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addbanklist()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['bankname'])||empty($_FILES['file1']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addbanklist');
					}
					else
					{
					if(isset($_FILES["file1"]))
			{
			$ext = end(explode(".",strtolower($_FILES['file1']['name'])));
			
			if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
					
					$basepath =  ROOT_PATH . "banklogo/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    else{
                            $this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
                    }
                    if(strlen($imgpath) > 4)
                    {
                        $bankid=$this->admin_model->insertbanklist($_POST['bankname'],$newfilename,$thumbfilename);
                    }
										
					if($bankid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Bank Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Bank Details not inserted.Try again');
						}}
						
						else
						{
							$this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
						}
					
					redirect(WEB_URL . 'home/addbanklist');
				}}
				
				$config['base_url'] = WEB_URL.'home/addbanklist/';
			$config['total_rows'] =$this->db->count_all('bankmaster');
			$config['per_page'] = '5';
			$config['uri_segment'] = 3;
			$this->pagination->initialize($config);
			$offset = (int)$this->uri->segment(3);
				$data['banklist']=$this->admin_model->fetchbanklistpage($offset,(int)$config['per_page']);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('banklist/banklistview',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addresidentialconstructionstage()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_FILES['file1'])||empty($_POST['category']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addresidentialconstructionstage');
					}
					else
					{
						if(isset($_FILES["file1"]))
			{
			$ext = end(explode(".",strtolower($_FILES['file1']['name'])));
			
			if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
					
					$basepath =  ROOT_PATH . "constructionstageimg/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    
                    if(strlen($imgpath) > 4)
                    {
                        $residentialconstructionstageid=$this->admin_model->insertresidentialconstructionstage($_POST['propertyname'],$_POST['stagedescription'],$newfilename,$thumbfilename);
                    }
			
			
					if($residentialconstructionstageid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Construction Stage Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Construction Stage Details not inserted.Try again');
						}}
						else
						{
							$this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
						}
					
					redirect(WEB_URL . 'home/addresidentialconstructionstage');
				}}
				
				//print_r($data);
				$data['propertycategoryname']=$this->admin_model->fetchcategorylist();
				$data['propertyname']=$this->admin_model->fetchproperty();
				$data['residentialconstruction']=$this->admin_model->fetchresidentialconstruction();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('constructionstage/addresidentialconstructionstage',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addcommercialconstructionstage()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_FILES['file1']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addcommercialconstructionstage');
					}
					else
					{
						if(isset($_FILES["file1"]))
			{
			$ext = end(explode(".",strtolower($_FILES['file1']['name'])));
			
			if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
					
					$basepath =  ROOT_PATH . "constructionstageimg/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    else{
                            $this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
                    }
                    if(strlen($imgpath) > 4)
                    {
                        $stageid=$this->admin_model->insertcommercialconstructionstage($_POST['propertyname'],$_POST['commercialstagedesc'],$newfilename,$thumbfilename);
                    }
			
									
					if($stageid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Construction Stage Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Construction Stage Details not inserted.Try again');
						}}
						
						else
						{
							$this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
						}
					
					redirect(WEB_URL . 'home/addcommercialconstructionstage');
				}}
				
				//print_r($data);
				$data['commercialcategory']=$this->admin_model->fetchcommercialcategoryname();

				//$data['commercialpropertyname']=$this->admin_model->fetchcommercialproperty();
				$data['commercialconstruction']=$this->admin_model->fetchcommercialconstruction();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('constructionstage/addcommercialconstructionstage',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addresidentialbrochure()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_FILES['file1']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addresidentialbrochure');
					}
					else
					{
						if(isset($_FILES['file1']['name']))
			{
				$ext = end(explode(".", $_FILES['file1']['name']));
                   
                    if(($ext == "pdf"))
					{	
			
			$name 	= rand(111111,888888) . "." . $ext;
			move_uploaded_file($_FILES['file1']['tmp_name'], ROOT_PATH .'brochureupload/'.$name);
			//$path=ROOT_PATH .'brochureupload/'.$name;
			
			
						$brochureid = $this->admin_model->insertresidentialbrochure($_POST['propertyname'],$name);
					if($brochureid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Residential brochure Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Residential brochure Details not inserted.Try again');
						}}
						else
						{
							$this->session->set_userdata('errmsg','Error:Invalid File format. Please upload pdf file only.');
						}
					
					
					redirect(WEB_URL . 'home/addresidentialbrochure');
				}}
				}
				//print_r($data);
				$data['propertyname']=$this->admin_model->fetchproperty();
			$data['propertycategoryname']=$this->admin_model->fetchcategorylist();	//$data['commercialelevation']=$this->admin_model->fetchcommercialelevation();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('brochure/addresidentialbrochure',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addcommercialbrochure()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_FILES['file1']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addcommercialbrochure');
					}
					else
					{
						if(isset($_FILES['file1']['name']))
			{
				$ext = end(explode(".", $_FILES['file1']['name']));
                   
                    if(($ext == "pdf"))
					{	
			
			$name 	= rand(111111,888888) . "." . $ext;
			move_uploaded_file($_FILES['file1']['tmp_name'], ROOT_PATH .'brochureupload/'.$name);
			//$path=ROOT_PATH .'brochureupload/'.$name;
			
			
						$brochureid = $this->admin_model->insertcommercialbrochure($_POST['propertyname'],$name);
					if($brochureid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Commercial brochure Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Commercial brochure Details not inserted.Try again');
						}}
						else
						{
							$this->session->set_userdata('errmsg','Error:Invalid File format. Please upload pdf file only.');
						}
					
					
					redirect(WEB_URL . 'home/addcommercialbrochure');
				}}
				}
				//print_r($data);
				//$data['propertyname']=$this->admin_model->fetchcommercialproperty();
				$data['commercialcategory']=$this->admin_model->fetchcommercialcategoryname();

				//$data['commercialelevation']=$this->admin_model->fetchcommercialelevation();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('brochure/addcommercialbrochure',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		
		function addresidentialpropertyvideo()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_FILES['file1']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addresidentialpropertyvideo');
					}
					else
					{
						if(isset($_FILES['file1']['name']))
			{
				$ext = end(explode(".", $_FILES['file1']['name']));
                   
                    if(($ext == "flv") || ($ext == "mp4"))
					{	
			
			$name 	= rand(111111,888888) . "." . $ext;
			move_uploaded_file($_FILES['file1']['tmp_name'], ROOT_PATH .'videoupload/'.$name);
			//$path=ROOT_PATH .'brochureupload/'.$name;
			
			
						$videoid = $this->admin_model->insertpropertyvideo($_POST['propertyname'],$name);
					if($videoid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Residential video Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Residential video Details not inserted.Try again');
						}}
						else
						{
							$this->session->set_userdata('errmsg','Error:Invalid File format. Please upload video file only.');
						}
					
					
					redirect(WEB_URL . 'home/addresidentialpropertyvideo');
				}}
				}
				//print_r($data);
				$data['propertyname']=$this->admin_model->fetchproperty();
			$data['propertycategoryname']=$this->admin_model->fetchcategorylist();	//$data['commercialelevation']=$this->admin_model->fetchcommercialelevation();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('video/addresidentialvideo',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		function addcommercialpropertyvideo()
		{
			if($this->session->userdata('uid') > 0)
			{
				if(isset($_POST['submit']))
				{
					if(empty($_POST['propertyname'])||empty($_FILES['file1']))
					{
					$this->session->set_userdata('errmsg','Error : Fields are Empty.Fill the Fields first.');
					redirect(WEB_URL . 'home/addcommercialpropertyvideo');
					}
					else
					{
						if(isset($_FILES['file1']['name']))
			{
				$ext = end(explode(".", $_FILES['file1']['name']));
                   
                    if(($ext == "flv") || ($ext == "mp4"))
					{	
			
			$name 	= rand(111111,888888) . "." . $ext;
			move_uploaded_file($_FILES['file1']['tmp_name'], ROOT_PATH .'videoupload/'.$name);
			//$path=ROOT_PATH .'brochureupload/'.$name;
			
			
						$videoid = $this->admin_model->insertcommercialpropertyvideo($_POST['propertyname'],$name);
					if($videoid > 0)
						{
							$this->session->set_userdata('errmsg','Message:Commercial video Details inserted successfully');
						}
						else
						{
							$this->session->set_userdata('errmsg','Error:Commercial video Details not inserted.Try again');
						}}
						else
						{
							$this->session->set_userdata('errmsg','Error:Invalid File format. Please upload video file only.');
						}
					
					
					redirect(WEB_URL . 'home/addcommercialpropertyvideo');
				}}
				}
				//print_r($data);
				//$data['propertyname']=$this->admin_model->fetchcommercialproperty();
				$data['commercialcategory']=$this->admin_model->fetchcommercialcategoryname();

				//$data['commercialelevation']=$this->admin_model->fetchcommercialelevation();
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('video/addcommercialvideo',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
			}
			else
			{
				redirect(WEB_URL . 'login/');
			}
		}
		
		
		
		
	//Edit Operation Starts
		
		function editcitylist()
		{
			$cityid=$this->uri->segment(3);
			$data['citydata']=$this->admin_model->editcitylist($cityid);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('edit/editcitylist',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
		}
		
		function updatecitylist()
		{
			if(isset($_POST['save']))
			{
			$cityid = $_POST['cityid'];
			$cityname = $_POST['cityname'];
			$value = $this->admin_model->updatecitylist($cityid,$cityname);
			redirect(WEB_URL . 'home/citylist');
			}
		}
		
		function editcityarealist()
		{
			$localityid=$this->uri->segment(3);
			$data['cityarea']=$this->admin_model->editcityarealist($localityid);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('edit/editcityarealist',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
		}
		
		function updatecityarealist()
		{
			if(isset($_POST['save']))
			{
			$localityid = $_POST['localityid'];
			$locality = $_POST['locality'];
			$value = $this->admin_model->updatecityarealist($localityid,$locality);
			redirect(WEB_URL . 'home/citylocation');
			}
		}
		
		function editbanklist()
		{
			$bankid=$this->uri->segment(3);
			$data['banklist']=$this->admin_model->editbanklist($bankid);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('edit/editbanklist',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
		}
		
		function updatebanklist()
		{
			if(isset($_POST['save']))
			{
			$bankid = $_POST['bankid'];
			$bankname = $_POST['bankname'];
			
			$value = $this->admin_model->updatebanklist($bankid,$bankname);
			}
			
			redirect(WEB_URL . 'home/addbanklist');
			
		}
		
		function editbanklogo()
		{
			$bankid=$this->uri->segment(3);
			$data['banklogo']=$this->admin_model->editbanklogo($bankid);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('edit/editbanklogo',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
		}
		
		function updatebanklogo()
		{
			if(isset($_POST['save']))
			{
			$bankid = $_POST['bankid'];
			$bankname = $_POST['bankname'];
			if(isset($_FILES["file1"]))
			{
			$ext = end(explode(".",strtolower($_FILES['file1']['name'])));
				if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
					
					$basepath =  ROOT_PATH . "banklogo/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    else{
                            $this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
                    }
                    if(strlen($imgpath) > 4)
                    {
                        $value = $this->admin_model->updatebanklogo($bankid,$newfilename,$thumbfilename);
                    }
					redirect(WEB_URL . 'home/addbanklist');
                }
			}
		}
		
		function editproptype()
		{
			$typeid=$this->uri->segment(3);
			$data['proptype']=$this->admin_model->editproptype($typeid);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('edit/editproptype',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
		}
		
		function updateproptype()
		{
			if(isset($_POST['save']))
			{
			$typeid = $_POST['typeid'];
			$proptype = $_POST['proptype'];
			$value = $this->admin_model->updateproptype($typeid,$proptype);
			redirect(WEB_URL . 'home/property_types');
			}
		}
		
		function editcategory()
		{
			$catid=$this->uri->segment(3);
			$data['catdata']=$this->admin_model->editcategory($catid);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('edit/editcategory',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
		}
		
		function updatecategory()
		{
			if(isset($_POST['save']))
			{
			$catid = $_POST['catid'];
			$category = $_POST['category'];
			$value = $this->admin_model->updatecategory($catid,$category);
			redirect(WEB_URL . 'home/category');
			}
		}
		
		function editprofessional()
		{
			$professionalid=$this->uri->segment(3);
			$data['professionaldata']=$this->admin_model->editprofessional($professionalid);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('edit/editprofessional',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
		}
		
		function updateprofessional()
		{
			if(isset($_POST['save']))
			{
			$professionalid = $_POST['professionalid'];
			$firstname=$_POST['firstname'];
			$lastname=$_POST['lastname'];
			$designation = $_POST['designation'];
			$value = $this->admin_model->updateprofessional($professionalid,$firstname,$lastname,$designation);
			redirect(WEB_URL . 'home/addprofessionals');
			}
		}
		
		function editresidentialspecification()
		{
			$specificationid=$this->uri->segment(3);
			$data['specificationdata']=$this->admin_model->editresidentialspecification($specificationid);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('edit/editresidentialspecification',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
		}
		
		function updateresidentialspecification()
		{
			if(isset($_POST['save']))
			{
			$specificationid = $_POST['specificationid'];
			$specificationname=$_POST['specificationname'];
			$value = $this->admin_model->updateresidentialspecification($specificationid,$specificationname);
			redirect(WEB_URL . 'home/addresidentialspecification');
			}
		}
		
		function editresidentialamenities()
		{
			$amenitiesid=$this->uri->segment(3);
			$data['amenitiesdata']=$this->admin_model->editresidentialamenities($amenitiesid);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('edit/editresidentialamenities',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
		}
		
		function updateresidentialamenities()
		{
			if(isset($_POST['save']))
			{
			$amenitiesid = $_POST['amenitiesid'];
			$amenitiesname=$_POST['amenitiesname'];
			$value = $this->admin_model->updateresidentialamenities($amenitiesid,$amenitiesname);
			redirect(WEB_URL . 'home/addresidentialamenities');
			}
		}
		
		function editresidentialplan()
		{
			$planid=$this->uri->segment(3);
			$data['residentialplandata']=$this->admin_model->editresidentialplan($planid);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('edit/editresidentialplan',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
		}
		
		function updateresidentialplan()
		{
			if(isset($_POST['save']))
			{
			$planid = $_POST['planid'];
			$plantype=$_POST['plantype'];
			$value = $this->admin_model->updateresidentialplan($planid,$plantype);
			redirect(WEB_URL . 'home/addresidentialplan');
			}
		}
		
		function editresidentialplanimage()
		{
			$planid=$this->uri->segment(3);
			$data['residentialplanimage']=$this->admin_model->editresidentialplan($planid);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('edit/editresidentialplanimage',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
		}
		
		function updateresidentialplanimage()
		{
			if(isset($_POST['save']))
			{
			$planid = $_POST['planid'];
			$bankname = $_POST['bankname'];
			if(isset($_FILES["file1"]))
			{
			$ext = end(explode(".",strtolower($_FILES['file1']['name'])));
				if(($ext == "jpg" || $ext =="jpeg" || $ext =="gif" || $ext =="png" || $ext =="bmp"))
					{
					
					$basepath =  ROOT_PATH . "planimg/";   
                $randomnumber = rand(1111111,8888888);
                $newfilename = $randomnumber . "." . $ext ;               
                $resizefilename = $randomnumber . "_img." . $ext ;               
                $thumbfilename = $randomnumber . "_thumb." . $ext ;               
                $target_path = $basepath . $newfilename ;               
                $resize_path = $basepath . $resizefilename ; 
				
				$fileupload = move_uploaded_file($_FILES['file1']['tmp_name'],$target_path);
				print $fileupload;
            if($fileupload == 1 )
                {                   
                    list($width, $height, $type, $attr) = getimagesize($target_path);                                       
                    if($width > 600){
                        $rwidth = 600;
                    }else{
                        $rwidth = $width;
                    }
                    if($height > 375)
                    {
                        $rheight = 375;
                    }else{
                        $rheight = $height;
                    }
					
					$config['image_library'] = 'gd2';
                    $config['source_image'] = $target_path;
                    $config['create_thumb'] = TRUE;
                    $config['maintain_ratio'] = TRUE;
                    $config['width'] = 75;
                    $config['height'] = 50;

                    $this->image_lib->initialize($config);                   
                    $this->image_lib->resize();                                       
                    $this->image_lib->clear();
					
					}               
                        if($fileupload == 1 )
                        {
                            $imgpath = $resizefilename;

                        }else{
                            $imgpath = "";   
                        }
                    }       
                    else{
                            $this->session->set_userdata('errmsg','Error:Invalid Image format. Please upload valid logo.');
                    }
                    if(strlen($imgpath) > 4)
                    {
                        $value = $this->admin_model->updateresidentialplanimage($planid,$newfilename,$thumbfilename);
                    }
					redirect(WEB_URL . 'home/addresidentialplan');
                }
			}
		}
		
		function editproperty()
		{
			$residentialpropid=$this->uri->segment(3);
			$catname=$this->admin_model->getcatnamefromid($residentialpropid);
			$data['categoryname']=$catname;
			
				$data['residentialpropdata']=$this->admin_model->editresidentialapptproperty($residentialpropid);
			
			
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('edit/editresidentialproperty',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
		}
		
		function editcommercialproperty()
		{
			$commercialpropid=$this->uri->segment(3);
			$data['commpropdata']=$this->admin_model->editcommercialproperty($commercialpropid);
			$this->load->view('layout/header.php');
			$this->load->view('layout/topmenu.php');
			$this->load->view('edit/editcommercialproperty',$data);
			$this->load->view('calendar/calendar.php');
			$this->load->view('layout/footer.php');
		}
		
		function updatecommercialproperty()
		{
			if(isset($_POST['save']))
			{
			$propertycommercialid = $_POST['propertycommercialid'];
			$propertyname=$_POST['propertyname'];
			$project=$_POST['project'];
			$buildername = $_POST['buildername'];
			$developer = $_POST['developer'];
			$address = $_POST['address'];
			$propertyprice = $_POST['propertyprice'];
			$propertybuiltuparea = $_POST['propertybuiltuparea'];
			$propertyfloors = $_POST['propertyfloors'];
			$propertycompletion = $_POST['propertycompletion'];
			$propertypossession = $_POST['propertypossession'];
			
			$where = stripslashes($_POST['address']);
        $whereurl = urlencode($where);
// Note - Google key is domain specific!
$location = file("http://maps.google.com/maps/geo?q=$whereurl
&output=csv&key=ABQIAAAAvp3__HwvT3VkixIIbsW0axQuKI_6t1bH2P0vC
I_Q8jfpn8qdNBQMnneljxh9czilkau_bYSCXteS_A");
// Sample - $location[0]="200,8,51.369318,-2.133457";
        list ($stat,$acc,$lat,$long) = explode(",",$location[0]);
			
			$value = $this->admin_model->updatecommercialproperty($propertycommercialid,$propertyname,$project,$buildername,$developer,$address,$propertyprice,$propertybuiltuparea,$propertyfloors,$propertycompletion,$propertypossession,$lat,$long);
			redirect(WEB_URL . 'home/addcommercialproperty/commercial');
			}
		}
		
		
		
		
		
		
		
		
		
		
	}
?>